home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / doors_1 / fd200.zip / FD_AVL.PAS < prev    next >
Pascal/Delphi Source File  |  1988-02-27  |  5KB  |  209 lines

  1. function modestr(s : mode): any_string;
  2. begin
  3.   case s of
  4.     CW     : modestr := 'CW';
  5.     AM     : modestr := 'AM';
  6.     FM     : modestr := 'FM';
  7.     SSB    : modestr := 'SB';
  8.     RTTY   : modestr := 'RY';
  9.     AMTOR  : modestr := 'MT';
  10.     PACKET : modestr := 'PK';
  11.   end;
  12. end;
  13.  
  14. function pmodstr(s : mode): any_string;
  15. begin
  16.   case s of
  17.     CW     : pmodstr := '    CW';
  18.     AM     : pmodstr := '    AM';
  19.     FM     : pmodstr := '    FM';
  20.     SSB    : pmodstr := '   SSB';
  21.     RTTY   : pmodstr := '  RTTY';
  22.     AMTOR  : pmodstr := ' AMTOR';
  23.     PACKET : pmodstr := 'PACKET';
  24.   end;
  25. end;
  26.  
  27. function bandstr(b : hamband): any_string;
  28. begin
  29.   case b of
  30.     B160   : bandstr := '160';
  31.     B80    : bandstr := ' 80';
  32.     B40    : bandstr := ' 40';
  33.     B20    : bandstr := ' 20';
  34.     B15    : bandstr := ' 15';
  35.     B10    : bandstr := ' 10';
  36.     B6     : bandstr := '  6';
  37.     B2     : bandstr := '  2';
  38.     B220   : bandstr := '220';
  39.     B440   : bandstr := '440';
  40.   end;
  41. end;
  42.  
  43. function check_mode(mode1, mode2 : mode): integer;
  44. begin
  45.   case mode1 of
  46.     CW, RTTY, AMTOR : case mode2 of
  47.                                CW, RTTY, AMTOR : check_mode := 0;
  48.                                AM, FM, SSB, PACKET : check_mode := 1;
  49.                              end;
  50.     AM, FM, SSB            : case mode2 of
  51.                                CW, RTTY, AMTOR : check_mode := -1;
  52.                                AM, FM, SSB            : check_mode := 0;
  53.                                PACKET                 : check_mode := 1;
  54.                              end;
  55.     PACKET : case mode2 of
  56.                PACKET : check_mode := 0;
  57.                else     check_mode := -1;
  58.              end;
  59.   end;
  60. end;
  61.  
  62. function cmp;
  63. begin
  64.   if (d1.callsign < d2.callsign)
  65.   then cmp := -1
  66.   else if (d1.callsign > d2.callsign)
  67.        then cmp := 1
  68.        else if (d1.band < d2.band)
  69.             then cmp := -1
  70.             else if (d1.band > d2.band)
  71.                  then cmp := 1
  72.                  else cmp := check_mode(d1.xmtmode,d2.xmtmode);
  73. end;
  74.  
  75. procedure print;
  76. var pkey : char;
  77. begin
  78.   with pdata do
  79.   begin
  80.     line_nbr := line_nbr + 1;
  81.     gotoxy(14,line_nbr);
  82.     writeln(callsign:6,
  83.             class:5,
  84.             pmodstr(xmtmode):7,
  85.             bandstr(band):4,
  86.             section: 15,
  87.             date:9,time:6);
  88.   end;
  89.   if line_nbr = 23 then
  90.   begin
  91.     gotoxy(14,24);
  92.     write('<ESC>ape to quit print, <Retrn> for next page ..');
  93.     repeat pkey := readkey until pkey in [#13,#27];
  94.     if pkey = #27 then escape := TRUE;
  95.     ClrScr;
  96.     line_nbr := 0;
  97.   end;
  98. end;
  99.  
  100. procedure fprint;
  101. begin
  102.   with pdata do
  103.     writeln(fd_file,callsign:6,
  104.                     class:3,
  105.                     modestr(xmtmode):2,
  106.                     bandstr(band):3,
  107.                     section: 14,
  108.                     date:8,time:5);
  109. end;
  110.  
  111. procedure read_file;
  112. var  filename : file_type;
  113.      source   : any_string;
  114.      point,i,error : integer;
  115.      fd_file : text;
  116.      p : LINK;
  117.  
  118.   procedure read_line;
  119.   var tstr : string[2];
  120.       bstr : string[3];
  121.   begin
  122.     with p^.leaf do
  123.     begin
  124.       readln(fd_file,callsign, class, tstr, bstr, section, date, time);
  125.       if tstr = 'PK' then xmtmode := PACKET
  126.         else if tstr = 'MT' then xmtmode := AMTOR
  127.           else if tstr = 'RY' then xmtmode := RTTY
  128.             else if tstr = 'SB' then xmtmode := SSB
  129.               else if tstr = 'FM' then xmtmode := FM
  130.                 else if tstr = 'AM' then xmtmode := AM
  131.                   else xmtmode := CW;
  132.       if bstr = '160' then band := B160
  133.         else if bstr = ' 80' then band := B80
  134.           else if bstr = ' 40' then band := B40
  135.             else if bstr = ' 20' then band := B20
  136.               else if bstr = ' 10' then band := B10
  137.                 else if bstr = '  6' then band := B6
  138.                   else if bstr = '  2' then band := B2
  139.                     else if bstr = '220' then band := B220
  140.                       else band := B440;
  141.     end;
  142.     add_to_score(p^.leaf);
  143.     insert(root,p);
  144.   end;
  145.  
  146. begin
  147.   get_file_name(filename,1,1,default_file,1,1,80,24);
  148.   if (filename = '') then filename := default_file;
  149.   default_file := filename;
  150.   assign(fd_file,filename);
  151.   {$I-}
  152.   reset(fd_file);
  153.   if (IOresult <> 0)
  154.   then
  155.     begin
  156.       ClrScr;
  157.       writeln('File not found');
  158.       writeln;
  159.       write('Press any key to continue..');
  160.       wait_for_key;
  161.       ClrScr;
  162.     end
  163.   else
  164.     begin
  165.       writeln;
  166.       while (NOT Eof(fd_file)) do
  167.       begin
  168.         p := talloc;
  169.         if (p <> NIL) then read_line;
  170.       end;
  171.     end;
  172.   close(fd_file);
  173. end;
  174.  
  175. procedure write_file(root: LINK);
  176. var  filename : file_type;
  177.      i : integer;
  178. begin
  179.   escape := FALSE;
  180.   for i := 0 to 1023 do map[i] := 0;
  181.   depth := -1;
  182.   window(1,1,80,24);
  183.   ClrScr;
  184.   get_file_name(filename,1,1,default_file,1,1,80,24);
  185.   if (filename = '') then filename := default_file;
  186.   assign(fd_file,filename);
  187.   {$I-}
  188.   rewrite(fd_file);
  189.   i := IOresult;
  190.   if (i <> 0)
  191.   then
  192.     begin
  193.       writeln; writeln('Unable to open file ',filename,' -  error = ',i);
  194.       write('Press any key to continue ...');
  195.       wait_for_key;
  196.       {$I-}
  197.       close(fd_file);
  198.       i := IOresult;
  199.     end
  200.   else
  201.   begin
  202.     writeln; write('Writing records ...');
  203.     trav( root, R, 1);
  204.     close(fd_file);
  205.   end;
  206.   window(1,1,80,25);
  207. end;
  208.  
  209.